In [1]:
import pandas as pdhouses = pd.read_csv("data/kc_house_data.csv")titanic = pd.read_csv("data/titanic.csv")netflix = pd.read_csv("data/netflix_titles.csv", sep="|", index_col=0)btc = pd.read_csv("data/coin_Bitcoin.csv")countries = pd.read_csv("data/world-happiness-report-2021.csv")
In [2]:
countries.set_index("Country name", inplace=True)
In [3]:
btc.drop(labels="Symbol", axis=1)
Out[3]:
SNo | Name | Date | High | Low | Open | Close | Volume | Marketcap | |
0 | 1 | Bitcoin | 2013-04-29 23:59:59 | 147.488007 | 134.000000 | 134.444000 | 144.539993 | 0.000000e+00 | 1.603769e+09 |
1 | 2 | Bitcoin | 2013-04-30 23:59:59 | 146.929993 | 134.050003 | 144.000000 | 139.000000 | 0.000000e+00 | 1.542813e+09 |
2 | 3 | Bitcoin | 2013-05-01 23:59:59 | 139.889999 | 107.720001 | 139.000000 | 116.989998 | 0.000000e+00 | 1.298955e+09 |
3 | 4 | Bitcoin | 2013-05-02 23:59:59 | 125.599998 | 92.281898 | 116.379997 | 105.209999 | 0.000000e+00 | 1.168517e+09 |
4 | 5 | Bitcoin | 2013-05-03 23:59:59 | 108.127998 | 79.099998 | 106.250000 | 97.750000 | 0.000000e+00 | 1.085995e+09 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
2986 | 2987 | Bitcoin | 2021-07-02 23:59:59 | 33939.588699 | 32770.680780 | 33549.600177 | 33897.048590 | 3.872897e+10 | 6.354508e+11 |
2987 | 2988 | Bitcoin | 2021-07-03 23:59:59 | 34909.259899 | 33402.696536 | 33854.421362 | 34668.548402 | 2.438396e+10 | 6.499397e+11 |
2988 | 2989 | Bitcoin | 2021-07-04 23:59:59 | 35937.567147 | 34396.477458 | 34665.564866 | 35287.779766 | 2.492431e+10 | 6.615748e+11 |
2989 | 2990 | Bitcoin | 2021-07-05 23:59:59 | 35284.344430 | 33213.661034 | 35284.344430 | 33746.002456 | 2.672155e+10 | 6.326962e+11 |
2990 | 2991 | Bitcoin | 2021-07-06 23:59:59 | 35038.536363 | 33599.916169 | 33723.509655 | 34235.193451 | 2.650126e+10 | 6.418992e+11 |
2991 rows × 9 columns
In [4]:
btc
Out[4]:
SNo | Name | Symbol | Date | High | Low | Open | Close | Volume | Marketcap | |
0 | 1 | Bitcoin | BTC | 2013-04-29 23:59:59 | 147.488007 | 134.000000 | 134.444000 | 144.539993 | 0.000000e+00 | 1.603769e+09 |
1 | 2 | Bitcoin | BTC | 2013-04-30 23:59:59 | 146.929993 | 134.050003 | 144.000000 | 139.000000 | 0.000000e+00 | 1.542813e+09 |
2 | 3 | Bitcoin | BTC | 2013-05-01 23:59:59 | 139.889999 | 107.720001 | 139.000000 | 116.989998 | 0.000000e+00 | 1.298955e+09 |
3 | 4 | Bitcoin | BTC | 2013-05-02 23:59:59 | 125.599998 | 92.281898 | 116.379997 | 105.209999 | 0.000000e+00 | 1.168517e+09 |
4 | 5 | Bitcoin | BTC | 2013-05-03 23:59:59 | 108.127998 | 79.099998 | 106.250000 | 97.750000 | 0.000000e+00 | 1.085995e+09 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
2986 | 2987 | Bitcoin | BTC | 2021-07-02 23:59:59 | 33939.588699 | 32770.680780 | 33549.600177 | 33897.048590 | 3.872897e+10 | 6.354508e+11 |
2987 | 2988 | Bitcoin | BTC | 2021-07-03 23:59:59 | 34909.259899 | 33402.696536 | 33854.421362 | 34668.548402 | 2.438396e+10 | 6.499397e+11 |
2988 | 2989 | Bitcoin | BTC | 2021-07-04 23:59:59 | 35937.567147 | 34396.477458 | 34665.564866 | 35287.779766 | 2.492431e+10 | 6.615748e+11 |
2989 | 2990 | Bitcoin | BTC | 2021-07-05 23:59:59 | 35284.344430 | 33213.661034 | 35284.344430 | 33746.002456 | 2.672155e+10 | 6.326962e+11 |
2990 | 2991 | Bitcoin | BTC | 2021-07-06 23:59:59 | 35038.536363 | 33599.916169 | 33723.509655 | 34235.193451 | 2.650126e+10 | 6.418992e+11 |
2991 rows × 10 columns
In [5]:
btc.drop(labels=["SNo", "Name", "Symbol"], axis='columns')
Out[5]:
Date | High | Low | Open | Close | Volume | Marketcap | |
0 | 2013-04-29 23:59:59 | 147.488007 | 134.000000 | 134.444000 | 144.539993 | 0.000000e+00 | 1.603769e+09 |
1 | 2013-04-30 23:59:59 | 146.929993 | 134.050003 | 144.000000 | 139.000000 | 0.000000e+00 | 1.542813e+09 |
2 | 2013-05-01 23:59:59 | 139.889999 | 107.720001 | 139.000000 | 116.989998 | 0.000000e+00 | 1.298955e+09 |
3 | 2013-05-02 23:59:59 | 125.599998 | 92.281898 | 116.379997 | 105.209999 | 0.000000e+00 | 1.168517e+09 |
4 | 2013-05-03 23:59:59 | 108.127998 | 79.099998 | 106.250000 | 97.750000 | 0.000000e+00 | 1.085995e+09 |
... | ... | ... | ... | ... | ... | ... | ... |
2986 | 2021-07-02 23:59:59 | 33939.588699 | 32770.680780 | 33549.600177 | 33897.048590 | 3.872897e+10 | 6.354508e+11 |
2987 | 2021-07-03 23:59:59 | 34909.259899 | 33402.696536 | 33854.421362 | 34668.548402 | 2.438396e+10 | 6.499397e+11 |
2988 | 2021-07-04 23:59:59 | 35937.567147 | 34396.477458 | 34665.564866 | 35287.779766 | 2.492431e+10 | 6.615748e+11 |
2989 | 2021-07-05 23:59:59 | 35284.344430 | 33213.661034 | 35284.344430 | 33746.002456 | 2.672155e+10 | 6.326962e+11 |
2990 | 2021-07-06 23:59:59 | 35038.536363 | 33599.916169 | 33723.509655 | 34235.193451 | 2.650126e+10 | 6.418992e+11 |
2991 rows × 7 columns
In [6]:
# btc.drop(labels=["SNo", "Name", "Symbol"], axis='columns')btc.drop(columns=["SNo", "Name", "Symbol"])
Out[6]:
Date | High | Low | Open | Close | Volume | Marketcap | |
0 | 2013-04-29 23:59:59 | 147.488007 | 134.000000 | 134.444000 | 144.539993 | 0.000000e+00 | 1.603769e+09 |
1 | 2013-04-30 23:59:59 | 146.929993 | 134.050003 | 144.000000 | 139.000000 | 0.000000e+00 | 1.542813e+09 |
2 | 2013-05-01 23:59:59 | 139.889999 | 107.720001 | 139.000000 | 116.989998 | 0.000000e+00 | 1.298955e+09 |
3 | 2013-05-02 23:59:59 | 125.599998 | 92.281898 | 116.379997 | 105.209999 | 0.000000e+00 | 1.168517e+09 |
4 | 2013-05-03 23:59:59 | 108.127998 | 79.099998 | 106.250000 | 97.750000 | 0.000000e+00 | 1.085995e+09 |
... | ... | ... | ... | ... | ... | ... | ... |
2986 | 2021-07-02 23:59:59 | 33939.588699 | 32770.680780 | 33549.600177 | 33897.048590 | 3.872897e+10 | 6.354508e+11 |
2987 | 2021-07-03 23:59:59 | 34909.259899 | 33402.696536 | 33854.421362 | 34668.548402 | 2.438396e+10 | 6.499397e+11 |
2988 | 2021-07-04 23:59:59 | 35937.567147 | 34396.477458 | 34665.564866 | 35287.779766 | 2.492431e+10 | 6.615748e+11 |
2989 | 2021-07-05 23:59:59 | 35284.344430 | 33213.661034 | 35284.344430 | 33746.002456 | 2.672155e+10 | 6.326962e+11 |
2990 | 2021-07-06 23:59:59 | 35038.536363 | 33599.916169 | 33723.509655 | 34235.193451 | 2.650126e+10 | 6.418992e+11 |
2991 rows × 7 columns
In [7]:
btc[["Date", "High", "Low"]]
Out[7]:
Date | High | Low | |
0 | 2013-04-29 23:59:59 | 147.488007 | 134.000000 |
1 | 2013-04-30 23:59:59 | 146.929993 | 134.050003 |
2 | 2013-05-01 23:59:59 | 139.889999 | 107.720001 |
3 | 2013-05-02 23:59:59 | 125.599998 | 92.281898 |
4 | 2013-05-03 23:59:59 | 108.127998 | 79.099998 |
... | ... | ... | ... |
2986 | 2021-07-02 23:59:59 | 33939.588699 | 32770.680780 |
2987 | 2021-07-03 23:59:59 | 34909.259899 | 33402.696536 |
2988 | 2021-07-04 23:59:59 | 35937.567147 | 34396.477458 |
2989 | 2021-07-05 23:59:59 | 35284.344430 | 33213.661034 |
2990 | 2021-07-06 23:59:59 | 35038.536363 | 33599.916169 |
2991 rows × 3 columns
In [8]:
btc.drop(columns=["SNo", "Name", "Symbol"], inplace=True)
In [9]:
btc
Out[9]:
Date | High | Low | Open | Close | Volume | Marketcap | |
0 | 2013-04-29 23:59:59 | 147.488007 | 134.000000 | 134.444000 | 144.539993 | 0.000000e+00 | 1.603769e+09 |
1 | 2013-04-30 23:59:59 | 146.929993 | 134.050003 | 144.000000 | 139.000000 | 0.000000e+00 | 1.542813e+09 |
2 | 2013-05-01 23:59:59 | 139.889999 | 107.720001 | 139.000000 | 116.989998 | 0.000000e+00 | 1.298955e+09 |
3 | 2013-05-02 23:59:59 | 125.599998 | 92.281898 | 116.379997 | 105.209999 | 0.000000e+00 | 1.168517e+09 |
4 | 2013-05-03 23:59:59 | 108.127998 | 79.099998 | 106.250000 | 97.750000 | 0.000000e+00 | 1.085995e+09 |
... | ... | ... | ... | ... | ... | ... | ... |
2986 | 2021-07-02 23:59:59 | 33939.588699 | 32770.680780 | 33549.600177 | 33897.048590 | 3.872897e+10 | 6.354508e+11 |
2987 | 2021-07-03 23:59:59 | 34909.259899 | 33402.696536 | 33854.421362 | 34668.548402 | 2.438396e+10 | 6.499397e+11 |
2988 | 2021-07-04 23:59:59 | 35937.567147 | 34396.477458 | 34665.564866 | 35287.779766 | 2.492431e+10 | 6.615748e+11 |
2989 | 2021-07-05 23:59:59 | 35284.344430 | 33213.661034 | 35284.344430 | 33746.002456 | 2.672155e+10 | 6.326962e+11 |
2990 | 2021-07-06 23:59:59 | 35038.536363 | 33599.916169 | 33723.509655 | 34235.193451 | 2.650126e+10 | 6.418992e+11 |
2991 rows × 7 columns
In [10]:
countries
Out[10]:
Regional indicator | Ladder score | Standard error of ladder score | upperwhisker | lowerwhisker | Logged GDP per capita | Social support | Healthy life expectancy | Freedom to make life choices | Generosity | Perceptions of corruption | Ladder score in Dystopia | Explained by: Log GDP per capita | Explained by: Social support | Explained by: Healthy life expectancy | Explained by: Freedom to make life choices | Explained by: Generosity | Explained by: Perceptions of corruption | Dystopia + residual | |
Country name | |||||||||||||||||||
Finland | Western Europe | 7.842 | 0.032 | 7.904 | 7.780 | 10.775 | 0.954 | 72.000 | 0.949 | -0.098 | 0.186 | 2.43 | 1.446 | 1.106 | 0.741 | 0.691 | 0.124 | 0.481 | 3.253 |
Denmark | Western Europe | 7.620 | 0.035 | 7.687 | 7.552 | 10.933 | 0.954 | 72.700 | 0.946 | 0.030 | 0.179 | 2.43 | 1.502 | 1.108 | 0.763 | 0.686 | 0.208 | 0.485 | 2.868 |
Switzerland | Western Europe | 7.571 | 0.036 | 7.643 | 7.500 | 11.117 | 0.942 | 74.400 | 0.919 | 0.025 | 0.292 | 2.43 | 1.566 | 1.079 | 0.816 | 0.653 | 0.204 | 0.413 | 2.839 |
Iceland | Western Europe | 7.554 | 0.059 | 7.670 | 7.438 | 10.878 | 0.983 | 73.000 | 0.955 | 0.160 | 0.673 | 2.43 | 1.482 | 1.172 | 0.772 | 0.698 | 0.293 | 0.170 | 2.967 |
Netherlands | Western Europe | 7.464 | 0.027 | 7.518 | 7.410 | 10.932 | 0.942 | 72.400 | 0.913 | 0.175 | 0.338 | 2.43 | 1.501 | 1.079 | 0.753 | 0.647 | 0.302 | 0.384 | 2.798 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
Lesotho | Sub-Saharan Africa | 3.512 | 0.120 | 3.748 | 3.276 | 7.926 | 0.787 | 48.700 | 0.715 | -0.131 | 0.915 | 2.43 | 0.451 | 0.731 | 0.007 | 0.405 | 0.103 | 0.015 | 1.800 |
Botswana | Sub-Saharan Africa | 3.467 | 0.074 | 3.611 | 3.322 | 9.782 | 0.784 | 59.269 | 0.824 | -0.246 | 0.801 | 2.43 | 1.099 | 0.724 | 0.340 | 0.539 | 0.027 | 0.088 | 0.648 |
Rwanda | Sub-Saharan Africa | 3.415 | 0.068 | 3.548 | 3.282 | 7.676 | 0.552 | 61.400 | 0.897 | 0.061 | 0.167 | 2.43 | 0.364 | 0.202 | 0.407 | 0.627 | 0.227 | 0.493 | 1.095 |
Zimbabwe | Sub-Saharan Africa | 3.145 | 0.058 | 3.259 | 3.030 | 7.943 | 0.750 | 56.201 | 0.677 | -0.047 | 0.821 | 2.43 | 0.457 | 0.649 | 0.243 | 0.359 | 0.157 | 0.075 | 1.205 |
Afghanistan | South Asia | 2.523 | 0.038 | 2.596 | 2.449 | 7.695 | 0.463 | 52.493 | 0.382 | -0.102 | 0.924 | 2.43 | 0.370 | 0.000 | 0.126 | 0.000 | 0.122 | 0.010 | 1.895 |
149 rows × 19 columns
In [11]:
countries.drop(labels="Denmark", axis=0)
Out[11]:
Regional indicator | Ladder score | Standard error of ladder score | upperwhisker | lowerwhisker | Logged GDP per capita | Social support | Healthy life expectancy | Freedom to make life choices | Generosity | Perceptions of corruption | Ladder score in Dystopia | Explained by: Log GDP per capita | Explained by: Social support | Explained by: Healthy life expectancy | Explained by: Freedom to make life choices | Explained by: Generosity | Explained by: Perceptions of corruption | Dystopia + residual | |
Country name | |||||||||||||||||||
Finland | Western Europe | 7.842 | 0.032 | 7.904 | 7.780 | 10.775 | 0.954 | 72.000 | 0.949 | -0.098 | 0.186 | 2.43 | 1.446 | 1.106 | 0.741 | 0.691 | 0.124 | 0.481 | 3.253 |
Switzerland | Western Europe | 7.571 | 0.036 | 7.643 | 7.500 | 11.117 | 0.942 | 74.400 | 0.919 | 0.025 | 0.292 | 2.43 | 1.566 | 1.079 | 0.816 | 0.653 | 0.204 | 0.413 | 2.839 |
Iceland | Western Europe | 7.554 | 0.059 | 7.670 | 7.438 | 10.878 | 0.983 | 73.000 | 0.955 | 0.160 | 0.673 | 2.43 | 1.482 | 1.172 | 0.772 | 0.698 | 0.293 | 0.170 | 2.967 |
Netherlands | Western Europe | 7.464 | 0.027 | 7.518 | 7.410 | 10.932 | 0.942 | 72.400 | 0.913 | 0.175 | 0.338 | 2.43 | 1.501 | 1.079 | 0.753 | 0.647 | 0.302 | 0.384 | 2.798 |
Norway | Western Europe | 7.392 | 0.035 | 7.462 | 7.323 | 11.053 | 0.954 | 73.300 | 0.960 | 0.093 | 0.270 | 2.43 | 1.543 | 1.108 | 0.782 | 0.703 | 0.249 | 0.427 | 2.580 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
Lesotho | Sub-Saharan Africa | 3.512 | 0.120 | 3.748 | 3.276 | 7.926 | 0.787 | 48.700 | 0.715 | -0.131 | 0.915 | 2.43 | 0.451 | 0.731 | 0.007 | 0.405 | 0.103 | 0.015 | 1.800 |
Botswana | Sub-Saharan Africa | 3.467 | 0.074 | 3.611 | 3.322 | 9.782 | 0.784 | 59.269 | 0.824 | -0.246 | 0.801 | 2.43 | 1.099 | 0.724 | 0.340 | 0.539 | 0.027 | 0.088 | 0.648 |
Rwanda | Sub-Saharan Africa | 3.415 | 0.068 | 3.548 | 3.282 | 7.676 | 0.552 | 61.400 | 0.897 | 0.061 | 0.167 | 2.43 | 0.364 | 0.202 | 0.407 | 0.627 | 0.227 | 0.493 | 1.095 |
Zimbabwe | Sub-Saharan Africa | 3.145 | 0.058 | 3.259 | 3.030 | 7.943 | 0.750 | 56.201 | 0.677 | -0.047 | 0.821 | 2.43 | 0.457 | 0.649 | 0.243 | 0.359 | 0.157 | 0.075 | 1.205 |
Afghanistan | South Asia | 2.523 | 0.038 | 2.596 | 2.449 | 7.695 | 0.463 | 52.493 | 0.382 | -0.102 | 0.924 | 2.43 | 0.370 | 0.000 | 0.126 | 0.000 | 0.122 | 0.010 | 1.895 |
148 rows × 19 columns
In [12]:
countries
Out[12]:
Regional indicator | Ladder score | Standard error of ladder score | upperwhisker | lowerwhisker | Logged GDP per capita | Social support | Healthy life expectancy | Freedom to make life choices | Generosity | Perceptions of corruption | Ladder score in Dystopia | Explained by: Log GDP per capita | Explained by: Social support | Explained by: Healthy life expectancy | Explained by: Freedom to make life choices | Explained by: Generosity | Explained by: Perceptions of corruption | Dystopia + residual | |
Country name | |||||||||||||||||||
Finland | Western Europe | 7.842 | 0.032 | 7.904 | 7.780 | 10.775 | 0.954 | 72.000 | 0.949 | -0.098 | 0.186 | 2.43 | 1.446 | 1.106 | 0.741 | 0.691 | 0.124 | 0.481 | 3.253 |
Denmark | Western Europe | 7.620 | 0.035 | 7.687 | 7.552 | 10.933 | 0.954 | 72.700 | 0.946 | 0.030 | 0.179 | 2.43 | 1.502 | 1.108 | 0.763 | 0.686 | 0.208 | 0.485 | 2.868 |
Switzerland | Western Europe | 7.571 | 0.036 | 7.643 | 7.500 | 11.117 | 0.942 | 74.400 | 0.919 | 0.025 | 0.292 | 2.43 | 1.566 | 1.079 | 0.816 | 0.653 | 0.204 | 0.413 | 2.839 |
Iceland | Western Europe | 7.554 | 0.059 | 7.670 | 7.438 | 10.878 | 0.983 | 73.000 | 0.955 | 0.160 | 0.673 | 2.43 | 1.482 | 1.172 | 0.772 | 0.698 | 0.293 | 0.170 | 2.967 |
Netherlands | Western Europe | 7.464 | 0.027 | 7.518 | 7.410 | 10.932 | 0.942 | 72.400 | 0.913 | 0.175 | 0.338 | 2.43 | 1.501 | 1.079 | 0.753 | 0.647 | 0.302 | 0.384 | 2.798 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
Lesotho | Sub-Saharan Africa | 3.512 | 0.120 | 3.748 | 3.276 | 7.926 | 0.787 | 48.700 | 0.715 | -0.131 | 0.915 | 2.43 | 0.451 | 0.731 | 0.007 | 0.405 | 0.103 | 0.015 | 1.800 |
Botswana | Sub-Saharan Africa | 3.467 | 0.074 | 3.611 | 3.322 | 9.782 | 0.784 | 59.269 | 0.824 | -0.246 | 0.801 | 2.43 | 1.099 | 0.724 | 0.340 | 0.539 | 0.027 | 0.088 | 0.648 |
Rwanda | Sub-Saharan Africa | 3.415 | 0.068 | 3.548 | 3.282 | 7.676 | 0.552 | 61.400 | 0.897 | 0.061 | 0.167 | 2.43 | 0.364 | 0.202 | 0.407 | 0.627 | 0.227 | 0.493 | 1.095 |
Zimbabwe | Sub-Saharan Africa | 3.145 | 0.058 | 3.259 | 3.030 | 7.943 | 0.750 | 56.201 | 0.677 | -0.047 | 0.821 | 2.43 | 0.457 | 0.649 | 0.243 | 0.359 | 0.157 | 0.075 | 1.205 |
Afghanistan | South Asia | 2.523 | 0.038 | 2.596 | 2.449 | 7.695 | 0.463 | 52.493 | 0.382 | -0.102 | 0.924 | 2.43 | 0.370 | 0.000 | 0.126 | 0.000 | 0.122 | 0.010 | 1.895 |
149 rows × 19 columns
In [13]:
countries.drop(["Denmark", "Iceland", "Finland"])
Out[13]:
Regional indicator | Ladder score | Standard error of ladder score | upperwhisker | lowerwhisker | Logged GDP per capita | Social support | Healthy life expectancy | Freedom to make life choices | Generosity | Perceptions of corruption | Ladder score in Dystopia | Explained by: Log GDP per capita | Explained by: Social support | Explained by: Healthy life expectancy | Explained by: Freedom to make life choices | Explained by: Generosity | Explained by: Perceptions of corruption | Dystopia + residual | |
Country name | |||||||||||||||||||
Switzerland | Western Europe | 7.571 | 0.036 | 7.643 | 7.500 | 11.117 | 0.942 | 74.400 | 0.919 | 0.025 | 0.292 | 2.43 | 1.566 | 1.079 | 0.816 | 0.653 | 0.204 | 0.413 | 2.839 |
Netherlands | Western Europe | 7.464 | 0.027 | 7.518 | 7.410 | 10.932 | 0.942 | 72.400 | 0.913 | 0.175 | 0.338 | 2.43 | 1.501 | 1.079 | 0.753 | 0.647 | 0.302 | 0.384 | 2.798 |
Norway | Western Europe | 7.392 | 0.035 | 7.462 | 7.323 | 11.053 | 0.954 | 73.300 | 0.960 | 0.093 | 0.270 | 2.43 | 1.543 | 1.108 | 0.782 | 0.703 | 0.249 | 0.427 | 2.580 |
Sweden | Western Europe | 7.363 | 0.036 | 7.433 | 7.293 | 10.867 | 0.934 | 72.700 | 0.945 | 0.086 | 0.237 | 2.43 | 1.478 | 1.062 | 0.763 | 0.685 | 0.244 | 0.448 | 2.683 |
Luxembourg | Western Europe | 7.324 | 0.037 | 7.396 | 7.252 | 11.647 | 0.908 | 72.600 | 0.907 | -0.034 | 0.386 | 2.43 | 1.751 | 1.003 | 0.760 | 0.639 | 0.166 | 0.353 | 2.653 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
Lesotho | Sub-Saharan Africa | 3.512 | 0.120 | 3.748 | 3.276 | 7.926 | 0.787 | 48.700 | 0.715 | -0.131 | 0.915 | 2.43 | 0.451 | 0.731 | 0.007 | 0.405 | 0.103 | 0.015 | 1.800 |
Botswana | Sub-Saharan Africa | 3.467 | 0.074 | 3.611 | 3.322 | 9.782 | 0.784 | 59.269 | 0.824 | -0.246 | 0.801 | 2.43 | 1.099 | 0.724 | 0.340 | 0.539 | 0.027 | 0.088 | 0.648 |
Rwanda | Sub-Saharan Africa | 3.415 | 0.068 | 3.548 | 3.282 | 7.676 | 0.552 | 61.400 | 0.897 | 0.061 | 0.167 | 2.43 | 0.364 | 0.202 | 0.407 | 0.627 | 0.227 | 0.493 | 1.095 |
Zimbabwe | Sub-Saharan Africa | 3.145 | 0.058 | 3.259 | 3.030 | 7.943 | 0.750 | 56.201 | 0.677 | -0.047 | 0.821 | 2.43 | 0.457 | 0.649 | 0.243 | 0.359 | 0.157 | 0.075 | 1.205 |
Afghanistan | South Asia | 2.523 | 0.038 | 2.596 | 2.449 | 7.695 | 0.463 | 52.493 | 0.382 | -0.102 | 0.924 | 2.43 | 0.370 | 0.000 | 0.126 | 0.000 | 0.122 | 0.010 | 1.895 |
146 rows × 19 columns
In [14]:
btc.sort_index(ascending=False, inplace=True)btc.drop(2990)
Out[14]:
Date | High | Low | Open | Close | Volume | Marketcap | |
2989 | 2021-07-05 23:59:59 | 35284.344430 | 33213.661034 | 35284.344430 | 33746.002456 | 2.672155e+10 | 6.326962e+11 |
2988 | 2021-07-04 23:59:59 | 35937.567147 | 34396.477458 | 34665.564866 | 35287.779766 | 2.492431e+10 | 6.615748e+11 |
2987 | 2021-07-03 23:59:59 | 34909.259899 | 33402.696536 | 33854.421362 | 34668.548402 | 2.438396e+10 | 6.499397e+11 |
2986 | 2021-07-02 23:59:59 | 33939.588699 | 32770.680780 | 33549.600177 | 33897.048590 | 3.872897e+10 | 6.354508e+11 |
2985 | 2021-07-01 23:59:59 | 35035.982712 | 32883.781226 | 35035.982712 | 33572.117653 | 3.783896e+10 | 6.293393e+11 |
... | ... | ... | ... | ... | ... | ... | ... |
4 | 2013-05-03 23:59:59 | 108.127998 | 79.099998 | 106.250000 | 97.750000 | 0.000000e+00 | 1.085995e+09 |
3 | 2013-05-02 23:59:59 | 125.599998 | 92.281898 | 116.379997 | 105.209999 | 0.000000e+00 | 1.168517e+09 |
2 | 2013-05-01 23:59:59 | 139.889999 | 107.720001 | 139.000000 | 116.989998 | 0.000000e+00 | 1.298955e+09 |
1 | 2013-04-30 23:59:59 | 146.929993 | 134.050003 | 144.000000 | 139.000000 | 0.000000e+00 | 1.542813e+09 |
0 | 2013-04-29 23:59:59 | 147.488007 | 134.000000 | 134.444000 | 144.539993 | 0.000000e+00 | 1.603769e+09 |
2990 rows × 7 columns
In [15]:
countries
Out[15]:
Regional indicator | Ladder score | Standard error of ladder score | upperwhisker | lowerwhisker | Logged GDP per capita | Social support | Healthy life expectancy | Freedom to make life choices | Generosity | Perceptions of corruption | Ladder score in Dystopia | Explained by: Log GDP per capita | Explained by: Social support | Explained by: Healthy life expectancy | Explained by: Freedom to make life choices | Explained by: Generosity | Explained by: Perceptions of corruption | Dystopia + residual | |
Country name | |||||||||||||||||||
Finland | Western Europe | 7.842 | 0.032 | 7.904 | 7.780 | 10.775 | 0.954 | 72.000 | 0.949 | -0.098 | 0.186 | 2.43 | 1.446 | 1.106 | 0.741 | 0.691 | 0.124 | 0.481 | 3.253 |
Denmark | Western Europe | 7.620 | 0.035 | 7.687 | 7.552 | 10.933 | 0.954 | 72.700 | 0.946 | 0.030 | 0.179 | 2.43 | 1.502 | 1.108 | 0.763 | 0.686 | 0.208 | 0.485 | 2.868 |
Switzerland | Western Europe | 7.571 | 0.036 | 7.643 | 7.500 | 11.117 | 0.942 | 74.400 | 0.919 | 0.025 | 0.292 | 2.43 | 1.566 | 1.079 | 0.816 | 0.653 | 0.204 | 0.413 | 2.839 |
Iceland | Western Europe | 7.554 | 0.059 | 7.670 | 7.438 | 10.878 | 0.983 | 73.000 | 0.955 | 0.160 | 0.673 | 2.43 | 1.482 | 1.172 | 0.772 | 0.698 | 0.293 | 0.170 | 2.967 |
Netherlands | Western Europe | 7.464 | 0.027 | 7.518 | 7.410 | 10.932 | 0.942 | 72.400 | 0.913 | 0.175 | 0.338 | 2.43 | 1.501 | 1.079 | 0.753 | 0.647 | 0.302 | 0.384 | 2.798 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
Lesotho | Sub-Saharan Africa | 3.512 | 0.120 | 3.748 | 3.276 | 7.926 | 0.787 | 48.700 | 0.715 | -0.131 | 0.915 | 2.43 | 0.451 | 0.731 | 0.007 | 0.405 | 0.103 | 0.015 | 1.800 |
Botswana | Sub-Saharan Africa | 3.467 | 0.074 | 3.611 | 3.322 | 9.782 | 0.784 | 59.269 | 0.824 | -0.246 | 0.801 | 2.43 | 1.099 | 0.724 | 0.340 | 0.539 | 0.027 | 0.088 | 0.648 |
Rwanda | Sub-Saharan Africa | 3.415 | 0.068 | 3.548 | 3.282 | 7.676 | 0.552 | 61.400 | 0.897 | 0.061 | 0.167 | 2.43 | 0.364 | 0.202 | 0.407 | 0.627 | 0.227 | 0.493 | 1.095 |
Zimbabwe | Sub-Saharan Africa | 3.145 | 0.058 | 3.259 | 3.030 | 7.943 | 0.750 | 56.201 | 0.677 | -0.047 | 0.821 | 2.43 | 0.457 | 0.649 | 0.243 | 0.359 | 0.157 | 0.075 | 1.205 |
Afghanistan | South Asia | 2.523 | 0.038 | 2.596 | 2.449 | 7.695 | 0.463 | 52.493 | 0.382 | -0.102 | 0.924 | 2.43 | 0.370 | 0.000 | 0.126 | 0.000 | 0.122 | 0.010 | 1.895 |
149 rows × 19 columns
In [16]:
countries.drop(countries.index[0])
Out[16]:
Regional indicator | Ladder score | Standard error of ladder score | upperwhisker | lowerwhisker | Logged GDP per capita | Social support | Healthy life expectancy | Freedom to make life choices | Generosity | Perceptions of corruption | Ladder score in Dystopia | Explained by: Log GDP per capita | Explained by: Social support | Explained by: Healthy life expectancy | Explained by: Freedom to make life choices | Explained by: Generosity | Explained by: Perceptions of corruption | Dystopia + residual | |
Country name | |||||||||||||||||||
Denmark | Western Europe | 7.620 | 0.035 | 7.687 | 7.552 | 10.933 | 0.954 | 72.700 | 0.946 | 0.030 | 0.179 | 2.43 | 1.502 | 1.108 | 0.763 | 0.686 | 0.208 | 0.485 | 2.868 |
Switzerland | Western Europe | 7.571 | 0.036 | 7.643 | 7.500 | 11.117 | 0.942 | 74.400 | 0.919 | 0.025 | 0.292 | 2.43 | 1.566 | 1.079 | 0.816 | 0.653 | 0.204 | 0.413 | 2.839 |
Iceland | Western Europe | 7.554 | 0.059 | 7.670 | 7.438 | 10.878 | 0.983 | 73.000 | 0.955 | 0.160 | 0.673 | 2.43 | 1.482 | 1.172 | 0.772 | 0.698 | 0.293 | 0.170 | 2.967 |
Netherlands | Western Europe | 7.464 | 0.027 | 7.518 | 7.410 | 10.932 | 0.942 | 72.400 | 0.913 | 0.175 | 0.338 | 2.43 | 1.501 | 1.079 | 0.753 | 0.647 | 0.302 | 0.384 | 2.798 |
Norway | Western Europe | 7.392 | 0.035 | 7.462 | 7.323 | 11.053 | 0.954 | 73.300 | 0.960 | 0.093 | 0.270 | 2.43 | 1.543 | 1.108 | 0.782 | 0.703 | 0.249 | 0.427 | 2.580 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
Lesotho | Sub-Saharan Africa | 3.512 | 0.120 | 3.748 | 3.276 | 7.926 | 0.787 | 48.700 | 0.715 | -0.131 | 0.915 | 2.43 | 0.451 | 0.731 | 0.007 | 0.405 | 0.103 | 0.015 | 1.800 |
Botswana | Sub-Saharan Africa | 3.467 | 0.074 | 3.611 | 3.322 | 9.782 | 0.784 | 59.269 | 0.824 | -0.246 | 0.801 | 2.43 | 1.099 | 0.724 | 0.340 | 0.539 | 0.027 | 0.088 | 0.648 |
Rwanda | Sub-Saharan Africa | 3.415 | 0.068 | 3.548 | 3.282 | 7.676 | 0.552 | 61.400 | 0.897 | 0.061 | 0.167 | 2.43 | 0.364 | 0.202 | 0.407 | 0.627 | 0.227 | 0.493 | 1.095 |
Zimbabwe | Sub-Saharan Africa | 3.145 | 0.058 | 3.259 | 3.030 | 7.943 | 0.750 | 56.201 | 0.677 | -0.047 | 0.821 | 2.43 | 0.457 | 0.649 | 0.243 | 0.359 | 0.157 | 0.075 | 1.205 |
Afghanistan | South Asia | 2.523 | 0.038 | 2.596 | 2.449 | 7.695 | 0.463 | 52.493 | 0.382 | -0.102 | 0.924 | 2.43 | 0.370 | 0.000 | 0.126 | 0.000 | 0.122 | 0.010 | 1.895 |
148 rows × 19 columns
In [17]:
countries.drop(countries.index[10:])
Out[17]:
Regional indicator | Ladder score | Standard error of ladder score | upperwhisker | lowerwhisker | Logged GDP per capita | Social support | Healthy life expectancy | Freedom to make life choices | Generosity | Perceptions of corruption | Ladder score in Dystopia | Explained by: Log GDP per capita | Explained by: Social support | Explained by: Healthy life expectancy | Explained by: Freedom to make life choices | Explained by: Generosity | Explained by: Perceptions of corruption | Dystopia + residual | |
Country name | |||||||||||||||||||
Finland | Western Europe | 7.842 | 0.032 | 7.904 | 7.780 | 10.775 | 0.954 | 72.0 | 0.949 | -0.098 | 0.186 | 2.43 | 1.446 | 1.106 | 0.741 | 0.691 | 0.124 | 0.481 | 3.253 |
Denmark | Western Europe | 7.620 | 0.035 | 7.687 | 7.552 | 10.933 | 0.954 | 72.7 | 0.946 | 0.030 | 0.179 | 2.43 | 1.502 | 1.108 | 0.763 | 0.686 | 0.208 | 0.485 | 2.868 |
Switzerland | Western Europe | 7.571 | 0.036 | 7.643 | 7.500 | 11.117 | 0.942 | 74.4 | 0.919 | 0.025 | 0.292 | 2.43 | 1.566 | 1.079 | 0.816 | 0.653 | 0.204 | 0.413 | 2.839 |
Iceland | Western Europe | 7.554 | 0.059 | 7.670 | 7.438 | 10.878 | 0.983 | 73.0 | 0.955 | 0.160 | 0.673 | 2.43 | 1.482 | 1.172 | 0.772 | 0.698 | 0.293 | 0.170 | 2.967 |
Netherlands | Western Europe | 7.464 | 0.027 | 7.518 | 7.410 | 10.932 | 0.942 | 72.4 | 0.913 | 0.175 | 0.338 | 2.43 | 1.501 | 1.079 | 0.753 | 0.647 | 0.302 | 0.384 | 2.798 |
Norway | Western Europe | 7.392 | 0.035 | 7.462 | 7.323 | 11.053 | 0.954 | 73.3 | 0.960 | 0.093 | 0.270 | 2.43 | 1.543 | 1.108 | 0.782 | 0.703 | 0.249 | 0.427 | 2.580 |
Sweden | Western Europe | 7.363 | 0.036 | 7.433 | 7.293 | 10.867 | 0.934 | 72.7 | 0.945 | 0.086 | 0.237 | 2.43 | 1.478 | 1.062 | 0.763 | 0.685 | 0.244 | 0.448 | 2.683 |
Luxembourg | Western Europe | 7.324 | 0.037 | 7.396 | 7.252 | 11.647 | 0.908 | 72.6 | 0.907 | -0.034 | 0.386 | 2.43 | 1.751 | 1.003 | 0.760 | 0.639 | 0.166 | 0.353 | 2.653 |
New Zealand | North America and ANZ | 7.277 | 0.040 | 7.355 | 7.198 | 10.643 | 0.948 | 73.4 | 0.929 | 0.134 | 0.242 | 2.43 | 1.400 | 1.094 | 0.785 | 0.665 | 0.276 | 0.445 | 2.612 |
Austria | Western Europe | 7.268 | 0.036 | 7.337 | 7.198 | 10.906 | 0.934 | 73.3 | 0.908 | 0.042 | 0.481 | 2.43 | 1.492 | 1.062 | 0.782 | 0.640 | 0.215 | 0.292 | 2.784 |
In [18]:
titanic["species"] = "human"titanic
Out[18]:
pclass | survived | name | sex | age | sibsp | parch | ticket | fare | cabin | embarked | boat | body | home.dest | species | |
0 | 1 | 1 | Allen, Miss. Elisabeth Walton | female | 29 | 0 | 0 | 24160 | 211.3375 | B5 | S | 2 | ? | St Louis, MO | human |
1 | 1 | 1 | Allison, Master. Hudson Trevor | male | 0.9167 | 1 | 2 | 113781 | 151.55 | C22 C26 | S | 11 | ? | Montreal, PQ / Chesterville, ON | human |
2 | 1 | 0 | Allison, Miss. Helen Loraine | female | 2 | 1 | 2 | 113781 | 151.55 | C22 C26 | S | ? | ? | Montreal, PQ / Chesterville, ON | human |
3 | 1 | 0 | Allison, Mr. Hudson Joshua Creighton | male | 30 | 1 | 2 | 113781 | 151.55 | C22 C26 | S | ? | 135 | Montreal, PQ / Chesterville, ON | human |
4 | 1 | 0 | Allison, Mrs. Hudson J C (Bessie Waldo Daniels) | female | 25 | 1 | 2 | 113781 | 151.55 | C22 C26 | S | ? | ? | Montreal, PQ / Chesterville, ON | human |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
1304 | 3 | 0 | Zabour, Miss. Hileni | female | 14.5 | 1 | 0 | 2665 | 14.4542 | ? | C | ? | 328 | ? | human |
1305 | 3 | 0 | Zabour, Miss. Thamine | female | ? | 1 | 0 | 2665 | 14.4542 | ? | C | ? | ? | ? | human |
1306 | 3 | 0 | Zakarian, Mr. Mapriededer | male | 26.5 | 0 | 0 | 2656 | 7.225 | ? | C | ? | 304 | ? | human |
1307 | 3 | 0 | Zakarian, Mr. Ortin | male | 27 | 0 | 0 | 2670 | 7.225 | ? | C | ? | ? | ? | human |
1308 | 3 | 0 | Zimmerman, Mr. Leo | male | 29 | 0 | 0 | 315082 | 7.875 | ? | S | ? | ? | ? | human |
1309 rows × 15 columns
In [19]:
houses.insert(0, "county", "King County")
In [20]:
houses
Out[20]:
county | id | date | price | bedrooms | bathrooms | sqft_living | sqft_lot | floors | waterfront | ... | grade | sqft_above | sqft_basement | yr_built | yr_renovated | zipcode | lat | long | sqft_living15 | sqft_lot15 | |
0 | King County | 7129300520 | 20141013T000000 | 221900.0 | 3 | 1.00 | 1180 | 5650 | 1.0 | 0 | ... | 7 | 1180 | 0 | 1955 | 0 | 98178 | 47.5112 | -122.257 | 1340 | 5650 |
1 | King County | 6414100192 | 20141209T000000 | 538000.0 | 3 | 2.25 | 2570 | 7242 | 2.0 | 0 | ... | 7 | 2170 | 400 | 1951 | 1991 | 98125 | 47.7210 | -122.319 | 1690 | 7639 |
2 | King County | 5631500400 | 20150225T000000 | 180000.0 | 2 | 1.00 | 770 | 10000 | 1.0 | 0 | ... | 6 | 770 | 0 | 1933 | 0 | 98028 | 47.7379 | -122.233 | 2720 | 8062 |
3 | King County | 2487200875 | 20141209T000000 | 604000.0 | 4 | 3.00 | 1960 | 5000 | 1.0 | 0 | ... | 7 | 1050 | 910 | 1965 | 0 | 98136 | 47.5208 | -122.393 | 1360 | 5000 |
4 | King County | 1954400510 | 20150218T000000 | 510000.0 | 3 | 2.00 | 1680 | 8080 | 1.0 | 0 | ... | 8 | 1680 | 0 | 1987 | 0 | 98074 | 47.6168 | -122.045 | 1800 | 7503 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
21608 | King County | 263000018 | 20140521T000000 | 360000.0 | 3 | 2.50 | 1530 | 1131 | 3.0 | 0 | ... | 8 | 1530 | 0 | 2009 | 0 | 98103 | 47.6993 | -122.346 | 1530 | 1509 |
21609 | King County | 6600060120 | 20150223T000000 | 400000.0 | 4 | 2.50 | 2310 | 5813 | 2.0 | 0 | ... | 8 | 2310 | 0 | 2014 | 0 | 98146 | 47.5107 | -122.362 | 1830 | 7200 |
21610 | King County | 1523300141 | 20140623T000000 | 402101.0 | 2 | 0.75 | 1020 | 1350 | 2.0 | 0 | ... | 7 | 1020 | 0 | 2009 | 0 | 98144 | 47.5944 | -122.299 | 1020 | 2007 |
21611 | King County | 291310100 | 20150116T000000 | 400000.0 | 3 | 2.50 | 1600 | 2388 | 2.0 | 0 | ... | 8 | 1600 | 0 | 2004 | 0 | 98027 | 47.5345 | -122.069 | 1410 | 1287 |
21612 | King County | 1523300157 | 20141015T000000 | 325000.0 | 2 | 0.75 | 1020 | 1076 | 2.0 | 0 | ... | 7 | 1020 | 0 | 2008 | 0 | 98144 | 47.5941 | -122.299 | 1020 | 1357 |
21613 rows × 22 columns
In [21]:
houses["sale_price"] = houses["price"]
In [22]:
houses
Out[22]:
county | id | date | price | bedrooms | bathrooms | sqft_living | sqft_lot | floors | waterfront | ... | sqft_above | sqft_basement | yr_built | yr_renovated | zipcode | lat | long | sqft_living15 | sqft_lot15 | sale_price | |
0 | King County | 7129300520 | 20141013T000000 | 221900.0 | 3 | 1.00 | 1180 | 5650 | 1.0 | 0 | ... | 1180 | 0 | 1955 | 0 | 98178 | 47.5112 | -122.257 | 1340 | 5650 | 221900.0 |
1 | King County | 6414100192 | 20141209T000000 | 538000.0 | 3 | 2.25 | 2570 | 7242 | 2.0 | 0 | ... | 2170 | 400 | 1951 | 1991 | 98125 | 47.7210 | -122.319 | 1690 | 7639 | 538000.0 |
2 | King County | 5631500400 | 20150225T000000 | 180000.0 | 2 | 1.00 | 770 | 10000 | 1.0 | 0 | ... | 770 | 0 | 1933 | 0 | 98028 | 47.7379 | -122.233 | 2720 | 8062 | 180000.0 |
3 | King County | 2487200875 | 20141209T000000 | 604000.0 | 4 | 3.00 | 1960 | 5000 | 1.0 | 0 | ... | 1050 | 910 | 1965 | 0 | 98136 | 47.5208 | -122.393 | 1360 | 5000 | 604000.0 |
4 | King County | 1954400510 | 20150218T000000 | 510000.0 | 3 | 2.00 | 1680 | 8080 | 1.0 | 0 | ... | 1680 | 0 | 1987 | 0 | 98074 | 47.6168 | -122.045 | 1800 | 7503 | 510000.0 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
21608 | King County | 263000018 | 20140521T000000 | 360000.0 | 3 | 2.50 | 1530 | 1131 | 3.0 | 0 | ... | 1530 | 0 | 2009 | 0 | 98103 | 47.6993 | -122.346 | 1530 | 1509 | 360000.0 |
21609 | King County | 6600060120 | 20150223T000000 | 400000.0 | 4 | 2.50 | 2310 | 5813 | 2.0 | 0 | ... | 2310 | 0 | 2014 | 0 | 98146 | 47.5107 | -122.362 | 1830 | 7200 | 400000.0 |
21610 | King County | 1523300141 | 20140623T000000 | 402101.0 | 2 | 0.75 | 1020 | 1350 | 2.0 | 0 | ... | 1020 | 0 | 2009 | 0 | 98144 | 47.5944 | -122.299 | 1020 | 2007 | 402101.0 |
21611 | King County | 291310100 | 20150116T000000 | 400000.0 | 3 | 2.50 | 1600 | 2388 | 2.0 | 0 | ... | 1600 | 0 | 2004 | 0 | 98027 | 47.5345 | -122.069 | 1410 | 1287 | 400000.0 |
21612 | King County | 1523300157 | 20141015T000000 | 325000.0 | 2 | 0.75 | 1020 | 1076 | 2.0 | 0 | ... | 1020 | 0 | 2008 | 0 | 98144 | 47.5941 | -122.299 | 1020 | 1357 | 325000.0 |
21613 rows × 23 columns
In [23]:
houses.insert(3, "num_bedrooms", houses["bedrooms"])
In [24]:
houses
Out[24]:
county | id | date | num_bedrooms | price | bedrooms | bathrooms | sqft_living | sqft_lot | floors | ... | sqft_above | sqft_basement | yr_built | yr_renovated | zipcode | lat | long | sqft_living15 | sqft_lot15 | sale_price | |
0 | King County | 7129300520 | 20141013T000000 | 3 | 221900.0 | 3 | 1.00 | 1180 | 5650 | 1.0 | ... | 1180 | 0 | 1955 | 0 | 98178 | 47.5112 | -122.257 | 1340 | 5650 | 221900.0 |
1 | King County | 6414100192 | 20141209T000000 | 3 | 538000.0 | 3 | 2.25 | 2570 | 7242 | 2.0 | ... | 2170 | 400 | 1951 | 1991 | 98125 | 47.7210 | -122.319 | 1690 | 7639 | 538000.0 |
2 | King County | 5631500400 | 20150225T000000 | 2 | 180000.0 | 2 | 1.00 | 770 | 10000 | 1.0 | ... | 770 | 0 | 1933 | 0 | 98028 | 47.7379 | -122.233 | 2720 | 8062 | 180000.0 |
3 | King County | 2487200875 | 20141209T000000 | 4 | 604000.0 | 4 | 3.00 | 1960 | 5000 | 1.0 | ... | 1050 | 910 | 1965 | 0 | 98136 | 47.5208 | -122.393 | 1360 | 5000 | 604000.0 |
4 | King County | 1954400510 | 20150218T000000 | 3 | 510000.0 | 3 | 2.00 | 1680 | 8080 | 1.0 | ... | 1680 | 0 | 1987 | 0 | 98074 | 47.6168 | -122.045 | 1800 | 7503 | 510000.0 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
21608 | King County | 263000018 | 20140521T000000 | 3 | 360000.0 | 3 | 2.50 | 1530 | 1131 | 3.0 | ... | 1530 | 0 | 2009 | 0 | 98103 | 47.6993 | -122.346 | 1530 | 1509 | 360000.0 |
21609 | King County | 6600060120 | 20150223T000000 | 4 | 400000.0 | 4 | 2.50 | 2310 | 5813 | 2.0 | ... | 2310 | 0 | 2014 | 0 | 98146 | 47.5107 | -122.362 | 1830 | 7200 | 400000.0 |
21610 | King County | 1523300141 | 20140623T000000 | 2 | 402101.0 | 2 | 0.75 | 1020 | 1350 | 2.0 | ... | 1020 | 0 | 2009 | 0 | 98144 | 47.5944 | -122.299 | 1020 | 2007 | 402101.0 |
21611 | King County | 291310100 | 20150116T000000 | 3 | 400000.0 | 3 | 2.50 | 1600 | 2388 | 2.0 | ... | 1600 | 0 | 2004 | 0 | 98027 | 47.5345 | -122.069 | 1410 | 1287 | 400000.0 |
21612 | King County | 1523300157 | 20141015T000000 | 2 | 325000.0 | 2 | 0.75 | 1020 | 1076 | 2.0 | ... | 1020 | 0 | 2008 | 0 | 98144 | 47.5941 | -122.299 | 1020 | 1357 | 325000.0 |
21613 rows × 24 columns
In [25]:
titanic.drop(columns=["species"], inplace=True)
In [26]:
titanic["sibsp"]
Out[26]:
0 0
1 1
2 1
3 1
4 1
..
1304 1
1305 1
1306 0
1307 0
1308 0
Name: sibsp, Length: 1309, dtype: int64
In [27]:
titanic["parch"]
Out[27]:
0 0
1 2
2 2
3 2
4 2
..
1304 0
1305 0
1306 0
1307 0
1308 0
Name: parch, Length: 1309, dtype: int64
In [28]:
titanic["sibsp"] + titanic["parch"]
Out[28]:
0 0
1 3
2 3
3 3
4 3
..
1304 1
1305 1
1306 0
1307 0
1308 0
Length: 1309, dtype: int64
In [29]:
titanic["num_relatives"] = titanic["sibsp"] + titanic["parch"]
In [30]:
titanic
Out[30]:
pclass | survived | name | sex | age | sibsp | parch | ticket | fare | cabin | embarked | boat | body | home.dest | num_relatives | |
0 | 1 | 1 | Allen, Miss. Elisabeth Walton | female | 29 | 0 | 0 | 24160 | 211.3375 | B5 | S | 2 | ? | St Louis, MO | 0 |
1 | 1 | 1 | Allison, Master. Hudson Trevor | male | 0.9167 | 1 | 2 | 113781 | 151.55 | C22 C26 | S | 11 | ? | Montreal, PQ / Chesterville, ON | 3 |
2 | 1 | 0 | Allison, Miss. Helen Loraine | female | 2 | 1 | 2 | 113781 | 151.55 | C22 C26 | S | ? | ? | Montreal, PQ / Chesterville, ON | 3 |
3 | 1 | 0 | Allison, Mr. Hudson Joshua Creighton | male | 30 | 1 | 2 | 113781 | 151.55 | C22 C26 | S | ? | 135 | Montreal, PQ / Chesterville, ON | 3 |
4 | 1 | 0 | Allison, Mrs. Hudson J C (Bessie Waldo Daniels) | female | 25 | 1 | 2 | 113781 | 151.55 | C22 C26 | S | ? | ? | Montreal, PQ / Chesterville, ON | 3 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
1304 | 3 | 0 | Zabour, Miss. Hileni | female | 14.5 | 1 | 0 | 2665 | 14.4542 | ? | C | ? | 328 | ? | 1 |
1305 | 3 | 0 | Zabour, Miss. Thamine | female | ? | 1 | 0 | 2665 | 14.4542 | ? | C | ? | ? | ? | 1 |
1306 | 3 | 0 | Zakarian, Mr. Mapriededer | male | 26.5 | 0 | 0 | 2656 | 7.225 | ? | C | ? | 304 | ? | 0 |
1307 | 3 | 0 | Zakarian, Mr. Ortin | male | 27 | 0 | 0 | 2670 | 7.225 | ? | C | ? | ? | ? | 0 |
1308 | 3 | 0 | Zimmerman, Mr. Leo | male | 29 | 0 | 0 | 315082 | 7.875 | ? | S | ? | ? | ? | 0 |
1309 rows × 15 columns
In [31]:
titanic.sort_values("num_relatives", ascending=False)
Out[31]:
pclass | survived | name | sex | age | sibsp | parch | ticket | fare | cabin | embarked | boat | body | home.dest | num_relatives | |
1177 | 3 | 0 | Sage, Mr. Frederick | male | ? | 8 | 2 | CA. 2343 | 69.55 | ? | S | ? | ? | ? | 10 |
1179 | 3 | 0 | Sage, Mr. John George | male | ? | 1 | 9 | CA. 2343 | 69.55 | ? | S | ? | ? | ? | 10 |
1173 | 3 | 0 | Sage, Miss. Constance Gladys | female | ? | 8 | 2 | CA. 2343 | 69.55 | ? | S | ? | ? | ? | 10 |
1170 | 3 | 0 | Sage, Master. Thomas Henry | male | ? | 8 | 2 | CA. 2343 | 69.55 | ? | S | ? | ? | ? | 10 |
1172 | 3 | 0 | Sage, Miss. Ada | female | ? | 8 | 2 | CA. 2343 | 69.55 | ? | S | ? | ? | ? | 10 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
598 | 2 | 1 | Wright, Miss. Marion | female | 26 | 0 | 0 | 220844 | 13.5 | ? | S | 9 | ? | Yoevil, England / Cottage Grove, OR | 0 |
599 | 2 | 0 | Yrois, Miss. Henriette ('Mrs Harbeck') | female | 24 | 0 | 0 | 248747 | 13 | ? | S | ? | ? | Paris | 0 |
600 | 3 | 0 | Abbing, Mr. Anthony | male | 42 | 0 | 0 | C.A. 5547 | 7.55 | ? | S | ? | ? | ? | 0 |
604 | 3 | 1 | Abelseth, Miss. Karen Marie | female | 16 | 0 | 0 | 348125 | 7.65 | ? | S | 16 | ? | Norway Los Angeles, CA | 0 |
1308 | 3 | 0 | Zimmerman, Mr. Leo | male | 29 | 0 | 0 | 315082 | 7.875 | ? | S | ? | ? | ? | 0 |
1309 rows × 15 columns
In [32]:
titanic[titanic["survived"] == 1].sort_values("num_relatives", ascending=False)
Out[32]:
pclass | survived | name | sex | age | sibsp | parch | ticket | fare | cabin | embarked | boat | body | home.dest | num_relatives | |
641 | 3 | 1 | Asplund, Master. Edvin Rojj Felix | male | 3 | 4 | 2 | 347077 | 31.3875 | ? | S | 15 | ? | Sweden Worcester, MA | 6 |
625 | 3 | 1 | Andersson, Miss. Erna Alexandra | female | 17 | 4 | 2 | 3101281 | 7.925 | ? | S | D | ? | Ruotsinphyhtaa, Finland New York, NY | 6 |
646 | 3 | 1 | Asplund, Mrs. Carl Oscar (Selma Augusta Emilia... | female | 38 | 1 | 5 | 347077 | 31.3875 | ? | S | 15 | ? | Sweden Worcester, MA | 6 |
643 | 3 | 1 | Asplund, Miss. Lillian Gertrud | female | 5 | 4 | 2 | 347077 | 31.3875 | ? | S | 15 | ? | Sweden Worcester, MA | 6 |
111 | 1 | 1 | Fortune, Miss. Alice Elizabeth | female | 24 | 3 | 2 | 19950 | 263 | C23 C25 C27 | S | 10 | ? | Winnipeg, MB | 5 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
597 | 2 | 1 | Williams, Mr. Charles Eugene | male | ? | 0 | 0 | 244373 | 13 | ? | S | 14 | ? | Harrow, England | 0 |
598 | 2 | 1 | Wright, Miss. Marion | female | 26 | 0 | 0 | 220844 | 13.5 | ? | S | 9 | ? | Yoevil, England / Cottage Grove, OR | 0 |
604 | 3 | 1 | Abelseth, Miss. Karen Marie | female | 16 | 0 | 0 | 348125 | 7.65 | ? | S | 16 | ? | Norway Los Angeles, CA | 0 |
605 | 3 | 1 | Abelseth, Mr. Olaus Jorgensen | male | 25 | 0 | 0 | 348122 | 7.65 | F G63 | S | A | ? | Perkins County, SD | 0 |
0 | 1 | 1 | Allen, Miss. Elisabeth Walton | female | 29 | 0 | 0 | 24160 | 211.3375 | B5 | S | 2 | ? | St Louis, MO | 0 |
500 rows × 15 columns
In [33]:
solo_passengers = titanic["num_relatives"] == 0titanic[solo_passengers].sex.value_counts().plot(kind="pie")
Out[33]:
<AxesSubplot:ylabel='sex'>

In [34]:
titanic.sex.value_counts().plot(kind="pie")
Out[34]:
<AxesSubplot:ylabel='sex'>

In [35]:
houses["price_sqft"] = houses["price"] / houses["sqft_living"]
In [36]:
houses
Out[36]:
county | id | date | num_bedrooms | price | bedrooms | bathrooms | sqft_living | sqft_lot | floors | ... | sqft_basement | yr_built | yr_renovated | zipcode | lat | long | sqft_living15 | sqft_lot15 | sale_price | price_sqft | |
0 | King County | 7129300520 | 20141013T000000 | 3 | 221900.0 | 3 | 1.00 | 1180 | 5650 | 1.0 | ... | 0 | 1955 | 0 | 98178 | 47.5112 | -122.257 | 1340 | 5650 | 221900.0 | 188.050847 |
1 | King County | 6414100192 | 20141209T000000 | 3 | 538000.0 | 3 | 2.25 | 2570 | 7242 | 2.0 | ... | 400 | 1951 | 1991 | 98125 | 47.7210 | -122.319 | 1690 | 7639 | 538000.0 | 209.338521 |
2 | King County | 5631500400 | 20150225T000000 | 2 | 180000.0 | 2 | 1.00 | 770 | 10000 | 1.0 | ... | 0 | 1933 | 0 | 98028 | 47.7379 | -122.233 | 2720 | 8062 | 180000.0 | 233.766234 |
3 | King County | 2487200875 | 20141209T000000 | 4 | 604000.0 | 4 | 3.00 | 1960 | 5000 | 1.0 | ... | 910 | 1965 | 0 | 98136 | 47.5208 | -122.393 | 1360 | 5000 | 604000.0 | 308.163265 |
4 | King County | 1954400510 | 20150218T000000 | 3 | 510000.0 | 3 | 2.00 | 1680 | 8080 | 1.0 | ... | 0 | 1987 | 0 | 98074 | 47.6168 | -122.045 | 1800 | 7503 | 510000.0 | 303.571429 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
21608 | King County | 263000018 | 20140521T000000 | 3 | 360000.0 | 3 | 2.50 | 1530 | 1131 | 3.0 | ... | 0 | 2009 | 0 | 98103 | 47.6993 | -122.346 | 1530 | 1509 | 360000.0 | 235.294118 |
21609 | King County | 6600060120 | 20150223T000000 | 4 | 400000.0 | 4 | 2.50 | 2310 | 5813 | 2.0 | ... | 0 | 2014 | 0 | 98146 | 47.5107 | -122.362 | 1830 | 7200 | 400000.0 | 173.160173 |
21610 | King County | 1523300141 | 20140623T000000 | 2 | 402101.0 | 2 | 0.75 | 1020 | 1350 | 2.0 | ... | 0 | 2009 | 0 | 98144 | 47.5944 | -122.299 | 1020 | 2007 | 402101.0 | 394.216667 |
21611 | King County | 291310100 | 20150116T000000 | 3 | 400000.0 | 3 | 2.50 | 1600 | 2388 | 2.0 | ... | 0 | 2004 | 0 | 98027 | 47.5345 | -122.069 | 1410 | 1287 | 400000.0 | 250.000000 |
21612 | King County | 1523300157 | 20141015T000000 | 2 | 325000.0 | 2 | 0.75 | 1020 | 1076 | 2.0 | ... | 0 | 2008 | 0 | 98144 | 47.5941 | -122.299 | 1020 | 1357 | 325000.0 | 318.627451 |
21613 rows × 25 columns
In [37]:
houses.sort_values("price_sqft", ascending=False)
Out[37]:
county | id | date | num_bedrooms | price | bedrooms | bathrooms | sqft_living | sqft_lot | floors | ... | sqft_basement | yr_built | yr_renovated | zipcode | lat | long | sqft_living15 | sqft_lot15 | sale_price | price_sqft | |
19336 | King County | 6021500970 | 20150407T000000 | 2 | 874950.0 | 2 | 1.00 | 1080 | 4000 | 1.0 | ... | 0 | 1940 | 0 | 98117 | 47.6902 | -122.387 | 1530 | 4240 | 874950.0 | 810.138889 |
4013 | King County | 724069059 | 20140509T000000 | 3 | 2400000.0 | 3 | 2.25 | 3000 | 11665 | 1.5 | ... | 0 | 2001 | 0 | 98075 | 47.5884 | -122.086 | 3000 | 15959 | 2400000.0 | 800.000000 |
10446 | King County | 1118000320 | 20150508T000000 | 4 | 3400000.0 | 4 | 4.00 | 4260 | 11765 | 2.0 | ... | 980 | 1939 | 2010 | 98112 | 47.6380 | -122.288 | 4260 | 10408 | 3400000.0 | 798.122066 |
8623 | King County | 6303400395 | 20150130T000000 | 1 | 325000.0 | 1 | 0.75 | 410 | 8636 | 1.0 | ... | 0 | 1953 | 0 | 98146 | 47.5077 | -122.357 | 1190 | 8636 | 325000.0 | 792.682927 |
9314 | King County | 4389200610 | 20141201T000000 | 2 | 903000.0 | 2 | 1.50 | 1140 | 7800 | 1.0 | ... | 0 | 1947 | 0 | 98004 | 47.6142 | -122.209 | 2020 | 7800 | 903000.0 | 792.105263 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
1385 | King County | 3342700465 | 20150123T000000 | 3 | 250000.0 | 3 | 1.50 | 2840 | 10182 | 1.0 | ... | 1330 | 1951 | 0 | 98056 | 47.5240 | -122.200 | 2210 | 9669 | 250000.0 | 88.028169 |
17197 | King County | 5111400086 | 20140512T000000 | 3 | 110000.0 | 3 | 1.00 | 1250 | 53143 | 1.0 | ... | 0 | 1945 | 0 | 98038 | 47.4235 | -122.051 | 1820 | 217800 | 110000.0 | 88.000000 |
13825 | King County | 5637200450 | 20141017T000000 | 5 | 257000.0 | 5 | 2.75 | 2930 | 10148 | 2.0 | ... | 0 | 2002 | 0 | 98059 | 47.4887 | -122.145 | 2930 | 8425 | 257000.0 | 87.713311 |
3785 | King County | 723049156 | 20140523T000000 | 3 | 149000.0 | 3 | 1.00 | 1700 | 8645 | 1.0 | ... | 0 | 1955 | 0 | 98146 | 47.4899 | -122.337 | 1500 | 7980 | 149000.0 | 87.647059 |
18262 | King County | 2891000610 | 20141211T000000 | 4 | 148900.0 | 4 | 1.75 | 1700 | 6000 | 1.0 | ... | 0 | 1967 | 0 | 98002 | 47.3252 | -122.208 | 1280 | 6000 | 148900.0 | 87.588235 |
21613 rows × 25 columns
In [38]:
houses.sort_values("price_sqft", ascending=False).head(50)["zipcode"].value_counts().plot(kind="bar")
Out[38]:
<AxesSubplot:>

In [39]:
btc.set_index("Date")
Out[39]:
High | Low | Open | Close | Volume | Marketcap | |
Date | ||||||
2021-07-06 23:59:59 | 35038.536363 | 33599.916169 | 33723.509655 | 34235.193451 | 2.650126e+10 | 6.418992e+11 |
2021-07-05 23:59:59 | 35284.344430 | 33213.661034 | 35284.344430 | 33746.002456 | 2.672155e+10 | 6.326962e+11 |
2021-07-04 23:59:59 | 35937.567147 | 34396.477458 | 34665.564866 | 35287.779766 | 2.492431e+10 | 6.615748e+11 |
2021-07-03 23:59:59 | 34909.259899 | 33402.696536 | 33854.421362 | 34668.548402 | 2.438396e+10 | 6.499397e+11 |
2021-07-02 23:59:59 | 33939.588699 | 32770.680780 | 33549.600177 | 33897.048590 | 3.872897e+10 | 6.354508e+11 |
... | ... | ... | ... | ... | ... | ... |
2013-05-03 23:59:59 | 108.127998 | 79.099998 | 106.250000 | 97.750000 | 0.000000e+00 | 1.085995e+09 |
2013-05-02 23:59:59 | 125.599998 | 92.281898 | 116.379997 | 105.209999 | 0.000000e+00 | 1.168517e+09 |
2013-05-01 23:59:59 | 139.889999 | 107.720001 | 139.000000 | 116.989998 | 0.000000e+00 | 1.298955e+09 |
2013-04-30 23:59:59 | 146.929993 | 134.050003 | 144.000000 | 139.000000 | 0.000000e+00 | 1.542813e+09 |
2013-04-29 23:59:59 | 147.488007 | 134.000000 | 134.444000 | 144.539993 | 0.000000e+00 | 1.603769e+09 |
2991 rows × 6 columns
In [40]:
btc["change"] = btc["Close"] - btc["Open"]
In [41]:
btc.sort_values("change", ascending=False)
Out[41]:
Date | High | Low | Open | Close | Volume | Marketcap | change | |
2842 | 2021-02-08 23:59:59 | 46203.931437 | 38076.322807 | 38886.827290 | 46196.463719 | 1.014672e+11 | 8.603427e+11 | 7309.636429 |
2919 | 2021-04-26 23:59:59 | 54288.002155 | 48852.796843 | 49077.792363 | 54021.754787 | 5.828404e+10 | 1.009780e+12 | 4943.962424 |
2863 | 2021-03-01 23:59:59 | 49784.015290 | 45115.093115 | 45159.503053 | 49631.241371 | 5.389130e+10 | 9.252355e+11 | 4471.738318 |
2853 | 2021-02-19 23:59:59 | 56113.650547 | 50937.275722 | 51675.981285 | 55888.133682 | 6.349550e+10 | 1.041381e+12 | 4212.152397 |
2923 | 2021-04-30 23:59:59 | 57900.719988 | 53129.600877 | 53568.663584 | 57750.177346 | 5.239593e+10 | 1.079670e+12 | 4181.513762 |
... | ... | ... | ... | ... | ... | ... | ... | ... |
2911 | 2021-04-18 23:59:59 | 61057.456509 | 52829.535926 | 60701.886093 | 56216.185002 | 9.746887e+10 | 1.050445e+12 | -4485.701091 |
2824 | 2021-01-21 23:59:59 | 35552.679497 | 30250.749639 | 35549.397409 | 30825.698506 | 7.564307e+10 | 5.735657e+11 | -4723.698903 |
2857 | 2021-02-23 23:59:59 | 54204.929756 | 45290.590268 | 54204.929756 | 48824.426869 | 1.061025e+11 | 9.099259e+11 | -5380.502887 |
2942 | 2021-05-19 23:59:59 | 43546.116485 | 30681.496912 | 42944.975447 | 37002.440466 | 1.263581e+11 | 6.924526e+11 | -5942.534981 |
2935 | 2021-05-12 23:59:59 | 57939.362415 | 49150.533875 | 56714.533167 | 49150.533875 | 7.521540e+10 | 9.195278e+11 | -7563.999292 |
2991 rows × 8 columns
In [42]:
btc["delta"] = btc["High"] - btc["Low"]
In [43]:
btc.sort_values("delta", ascending=False)
Out[43]:
Date | High | Low | Open | Close | Volume | Marketcap | change | delta | |
2942 | 2021-05-19 23:59:59 | 43546.116485 | 30681.496912 | 42944.975447 | 37002.440466 | 1.263581e+11 | 6.924526e+11 | -5942.534981 | 12864.619573 |
2857 | 2021-02-23 23:59:59 | 54204.929756 | 45290.590268 | 54204.929756 | 48824.426869 | 1.061025e+11 | 9.099259e+11 | -5380.502887 | 8914.339488 |
2935 | 2021-05-12 23:59:59 | 57939.362415 | 49150.533875 | 56714.533167 | 49150.533875 | 7.521540e+10 | 9.195278e+11 | -7563.999292 | 8788.828540 |
2856 | 2021-02-22 23:59:59 | 57533.389325 | 48967.565188 | 57532.738864 | 54207.319065 | 9.205242e+10 | 1.010205e+12 | -3325.419799 | 8565.824137 |
2944 | 2021-05-21 23:59:59 | 42172.173616 | 33616.453884 | 40596.948323 | 37304.690671 | 8.205162e+10 | 6.981088e+11 | -3292.257651 | 8555.719732 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
871 | 2015-09-17 23:59:59 | 230.285004 | 228.925995 | 229.076004 | 229.809998 | 1.893540e+07 | 3.360247e+09 | 0.733994 | 1.359009 |
768 | 2015-06-06 23:59:59 | 225.718994 | 224.378998 | 225.005005 | 225.619003 | 1.113150e+07 | 3.213723e+09 | 0.613998 | 1.339996 |
759 | 2015-05-28 23:59:59 | 237.824005 | 236.651993 | 237.257004 | 237.408005 | 1.382960e+07 | 3.373817e+09 | 0.151001 | 1.172012 |
888 | 2015-10-04 23:59:59 | 238.968002 | 237.940002 | 238.531006 | 238.259003 | 1.299900e+07 | 3.499387e+09 | -0.272003 | 1.028000 |
100 | 2013-08-07 23:59:59 | 106.750000 | 106.750000 | 106.750000 | 106.750000 | 0.000000e+00 | 1.229098e+09 | 0.000000 | 0.000000 |
2991 rows × 9 columns
In [44]:
btc.set_index("Date", inplace=True)
In [45]:
btc.sort_values("delta", ascending=False).head(10)["delta"].plot(kind="bar")
Out[45]:
<AxesSubplot:xlabel='Date'>
